package com.ld.admin.websocket.chat;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;
import javax.websocket.HandshakeResponse;
import javax.websocket.server.HandshakeRequest;
import javax.websocket.server.ServerEndpointConfig;
import javax.websocket.server.ServerEndpointConfig.Configurator;

/**
 * 参数设置
 * 
 * @ClassName HttpSessionConfigurator
 * @author <a href="mailto:donggongai@126.com" target="_blank">吕凯</a>
 * @date 2019年2月28日 下午1:37:39
 *
 */
public class ChatConfigurator extends Configurator {

    @Override
    public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
        HttpSession httpSession = (HttpSession) request.getHttpSession(); // 获取httpSession
        Map<String, List<String>> headers = request.getHeaders();
        sec.getUserProperties().put(HttpSession.class.getName(), httpSession);
        sec.getUserProperties().put("headers", headers);
    }
}